using Circus.CodeEditor;
using System;
using System.Drawing;
namespace Circus.Syntax
{
	[Serializable]
	public class SyntaxAttribute :  ICloneable
	{
		private string name = string.Empty;
		private object _value;
		private Point position = Point.Empty;
		private Point endPosition = new Point(-1, -1);
		public virtual string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if (this.name != value)
				{
					this.name = value;
					this.OnNameChanged();
				}
			}
		}
		public virtual object Value
		{
			get
			{
				return this._value;
			}
			set
			{
				if (this._value != value)
				{
					this._value = value;
					this.OnValueChanged();
				}
			}
		}
		public virtual Point Position
		{
			get
			{
				return this.position;
			}
			set
			{
				if (this.position != value)
				{
					this.position = value;
					this.OnPositionChanged();
				}
			}
		}
		public virtual Point EndPosition
		{
			get
			{
				return (this.endPosition.Y >= 0) ? this.endPosition : new Point(this.position.X + ((this._value != null) ? this._value.ToString().Length : 0), this.position.Y);
			}
			set
			{
				this.endPosition = value;
			}
		}
		public virtual Range Range
		{
			get
			{
				return new Range(this.Position, this.EndPosition);
			}
		}
		protected virtual void OnNameChanged()
		{
		}
		protected virtual void OnValueChanged()
		{
		}
		protected virtual void OnPositionChanged()
		{
		}
		public SyntaxAttribute()
		{
		}
		public SyntaxAttribute(Point position, string name, object value)
		{
			this.position = position;
			this.name = name;
			this._value = value;
		}
		public override string ToString()
		{
			return (this.name != string.Empty) ? this.name : base.ToString();
		}
		public virtual object Clone()
		{
			return new SyntaxAttribute
			{
				Name = this.name,
				Value = this._value,
				Position = this.position,
				EndPosition = this.endPosition
			};
		}
	}
}
